#property indicator_chart_window

#include <MarketNewsLib.mqh>

//---- input parameters
extern int time_zone_gmt     =0; // London GMT.. adjust to 1 for day light saving
extern int update_interval   = 15; 
extern color session_upcoming_title_color = White;
extern color bar_closing_color = Lime;
extern color session_closing_color = Red;
extern bool show_news_lines  = true;
extern bool show_line_text   = true;        
extern color news_past_color = Gray;            
extern color news_high_color   = Red;         
extern color news_medium_color = Yellow;         
extern color news_low_color    = Orange;  
extern string news_url       = "http://www.dailyfx.com/files/";
extern int news_alert_min    = 3600; //1 hour news will be d
extern bool   show_low_news     = false;
extern bool   show_medium_news  = false;
extern bool   show_high_news    = true;
 
datetime lastUpdate = 0;      
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//--- Time zones
// New York = GMT-5, London = GMT+0, Tokyo = GMT+9, Sydney = GMT+10
//string RiskReward_ratio = (TP_price - Open_Price) / (Open_Price - SL_price);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   DeleteNewsObjects(); 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   
   DisplayTodaysNews();
   
   return(0);
  }


//+------------------------------------------------------------------+ 

int DisplayTodaysNews()
{
   string news[1000][10];
   datetime time = TimeCurrent();
   if(time >= lastUpdate+update_interval*60)  
   {   
     DeleteNewsObjects();
     lastUpdate = time;
     string str = "";
     InitNews(news,time_zone_gmt,news_url );
     if(show_news_lines) 
     DrawNewsLines(news, show_line_text,show_high_news, news_high_color, show_medium_news, news_medium_color, show_low_news, news_low_color);
   } 
   ShowNewsCountDown(news,news_alert_min,1, news_high_color, news_medium_color, news_low_color,news_past_color,session_upcoming_title_color);
   return(0);
}

